<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--enctype编码类型设置为多部分表单数据-->
<form action="" enctype="multipart/form-data">
    <input type="file" name="pic">
    <input type="button" value="上传" @click="send()">
    <img src="url" alt="">
</form>
<!--引入axios框架-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<!--引入vue框架-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    let v=new Vue({
        el:"form",
        data:{
            url:""
        },
        methods:{
            send:function () {
                //得到表单数据
                let data=new FormData(document.querySelector("form"));
                //发出异步请求
                axios.post("/send",data).then(function (response) {
                    alert("上传完成！");
                    v.url=response.data;
                })
            }
        }
    })
</script>
</body>
</html>